package Work02_List;

import java.util.ArrayList;
import java.util.Iterator;

public class ArrayListTest {
    public static void main(String[] args) {
        ArrayList<Integer> list=new ArrayList<>();
        list.add(23);      list.add(13);      list.add(33);      list.add(32);      list.add(54);
        for (int i = 0; i < list.size(); i++) {
            System.out.print(list.get(i)+",   ");
        }
        System.out.println();
        System.out.println("-----------------------------------------------------------------");
        Iterator<Integer> iterator = list.iterator();
        while (iterator.hasNext()) {
            Integer next = iterator.next();
            System.out.print(next+",   ");
        }
        System.out.println();
        System.out.println("-----------------------------------------------------------------");
        for (Integer integer : list) {
            System.out.print(integer+",   ");
        }
        System.out.println(listTest(list,23));

    }
    public static int listTest(ArrayList<Integer> list, Integer num){
        for (int i = 0; i < list.size(); i++) {
            if (num.equals(list.get(i))){
                return i;
            }
        }
        return -1;
        }
    }

